﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuanLyThongTinNhanKhau.GUI
{
    public partial class Login : Form
    {
        public delegate void SendData(object sender, string strSend);
        public event SendData sendData;

        model.BO.LoginBO loginBO;

        public Login()
        {
            InitializeComponent();
        }

        private void Login_Load(object sender, EventArgs e)
        {
            loginBO = new model.BO.LoginBO(this);
            this.lblMessage.Text = "";
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            String result = loginBO.btnLoginClick();

            if (result != "")
            {
                sendData(this, result);
                this.Close();
            }
        }

        private void txtPassword_Enter(object sender, EventArgs e)
        {
            btnLogin_Click(sender, e);
        }

        private void txtPassword_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                btnLogin_Click(sender, e);
            }
        }
    }
}
